import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { URL, fileURLToPath } from 'node:url'

import svgrPlugin from '@arco-plugins/vite-plugin-svgr'
import { vitePluginForArco } from '@arco-plugins/vite-react'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(fileURLToPath(new URL('.', import.meta.url)), 'src/')
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000/',
        changeOrigin: true
        // rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  plugins: [
    react(),

    svgrPlugin({
      svgrOptions: {}
    }),
    vitePluginForArco({
      modifyVars: {
        'arcoblue-6': '#165DFF'
      }
    })
  ]
})
